{template "common/header"}
<style type="text/css">
    .col-sm-2 {
        width: 11%;
    }

    .xh-toast-block {
        min-width: 300px;
        position: fixed;
        z-index: 9999;
        font-size: 18px;
        color: #e7e7e7;
        padding: 10px 20px;
        background: rgba(0, 0, 0, 0.7);
        left: 50%;
        top: 50%;
        line-height: 40px;
        border-radius: 10px;
        text-align: center;
        margin-top: -30px;
        margin-left: -150px;
    }

    .modeladd li {
        padding-top: 5px;
        padding-bottom: 5px;
        list-style: none;
        width: 100%;
        float: left;
    }
</style>
<ul class="nav nav-tabs">
    <li {if $op=='list'}class="active"{/if}>
    <a href="{php echo $this->createWebUrl('lesson',array('op'=>'list'))}">课程列表</a>
    </li>
    <li {if $op=='post'}class="active"{/if}>
    <a href="{php echo $this->createWebUrl('lesson',array('op'=>'post'))}">{if empty($info['id'])}添加课程{else}修改课程{/if}</a>
    </li>
    {if $op == 'underline_list' || $op == 'editunderline'}
    <li class="active">
    <a href="{php echo $this->createWebUrl('lesson',array('op'=>'underline_list', 'lesson_id'=>$lesson_id))}">线下学员名单</a>
    </li>
    {/if}
</ul>
{if $op == 'list'}
<div class="list-group">
    <div active="list-group-item" style="border:1px solid #cecece">
        <form action="./index.php" method="get" class="form-horizontal">
            <p class="list-group-item" style="background-color: #D9EDF7;position: relative;">按条件搜索 </p>

            <input type="hidden" name="c" value="site">
            <input type="hidden" name="a" value="entry">
            <input type="hidden" name="m" value="goouc_class">
            <input type="hidden" name="do" value="lesson">
            <div class="form-group col-sm-3" style="margin-bottom:10px;margin-top: 10px;">
                <label class="col-sm-4 control-label">课程名称：</label>
                <div class="col-sm-8" style="padding:0px">
                    <input type="text" name="kname" value="{$kname}" class="form-control"/>
                </div>
            </div>

            <div class="form-group col-sm-3" style="margin-bottom:10px;margin-top: 10px">
                <label class="col-sm-4 control-label">学科：</label>
                <select name="subjectid" class="col-sm-8">
                    <option value="">--请选择--</option>
                    {loop $subject $s}
                    <option value="{$s['id']}" class="form-control" {if $subjectid== $s['id']}selected{/if}>{$s['name']}</option>
                    {/loop}
                </select>
            </div>
            <div class="form-group col-sm-3" style="margin-bottom:10px;margin-top: 10px">
                <label class="col-sm-4 control-label">讲师：</label>
                <select name="teacherid" class="col-sm-8">
                    <option value="">--请选择--</option>
                    {loop $teacher $t}
                    <option value="{$t['id']}" class="form-control" {if $teacherid== $t['id']}selected{/if}>{$t['name']}</option>
                    {/loop}
                </select>
            </div>
            <div class="form-group col-sm-3" style="margin-bottom:10px;margin-top: 10px">
                <label class="col-sm-4 control-label">年级：</label>
                <select name="classid" class="col-sm-8">
                    <option value="">--请选择--</option>
                    {loop $class $cl}
                    <option value="{$cl['id']}" class="form-control" {if $classid== $cl['id']}selected{/if}>{$cl['name']}</option>
                    {/loop}
                </select>
            </div>
            <div class="form-group col-sm-3" style="margin-bottom:10px">
                <label class="col-sm-4 control-label">学期：</label>
                <select name="semesterid" class="col-sm-8">
                    <option value="">--请选择--</option>
                    {loop $semester $se}
                    <option value="{$se['id']}" class="form-control" {if $semesterid== $se['id']}selected{/if}>{$se['name']}</option>
                    {/loop}
                </select>
            </div>
            <div class="form-group col-sm-3" style="margin-bottom:10px">
                <label class="col-sm-4 control-label">视频类型：</label>
                <select name="voidtypeid" class="col-sm-8">
                    <option value="">--请选择--</option>
                    {loop $voidtype $v}
                    <option value="{$v['id']}" class="form-control" {if $voidtypeid== $v['id']}selected{/if}>{$v['name']}</option>
                    {/loop}
                </select>
            </div>

            <div class="form-group col-sm-3" style="margin-bottom:10px">
                <label class="col-sm-4 control-label">课次：</label>
                <select name="isonly" class="col-sm-8">
                    <option value="">--请选择--</option>
                    <option value="1" {if $isonly == 1}selected{/if}>单章节课</option>
                    <option value="2" {if $isonly == 2}selected{/if}>系列课</option>
                </select>
            </div>

            <div class="form-group col-sm-3" style="margin-bottom:10px">
                <label class="col-sm-4 control-label">课程价格：</label>
                <select name="price_type" class="col-sm-8">
                    <option value="">--请选择--</option>
                    <option value="1" {if $price_status == 1}selected{/if}>免费</option>
                    <option value="2" {if $price_status == 2}selected{/if}>付费</option>
                </select>
            </div>

            <div class="form-group col-sm-3" style="margin-bottom:10px;">
                <label class="col-sm-4 control-label">月份：</label>

                <select name="date" id="" class="col-sm-8">
                    <option value="">--选择月份--</option>
                    <option value="1" {if $date == 1}selected{/if}>1月</option>
                    <option value="2" {if $date == 2}selected{/if}>2月</option>
                    <option value="3" {if $date == 3}selected{/if}>3月</option>
                    <option value="4" {if $date == 4}selected{/if}>4月</option>
                    <option value="5" {if $date == 5}selected{/if}>5月</option>
                    <option value="6" {if $date == 6}selected{/if}>6月</option>
                    <option value="7" {if $date == 7}selected{/if}>7月</option>
                    <option value="8" {if $date == 8}selected{/if}>8月</option>
                    <option value="9" {if $date == 9}selected{/if}>9月</option>
                    <option value="10" {if $date == 10}selected{/if}>10月</option>
                    <option value="11" {if $date == 11}selected{/if}>11月</option>
                    <option value="12" {if $date == 12}selected{/if}>12月</option>
                </select>
            </div>

            <div class="form-group col-sm-3" style="margin-bottom:10px;">
                <label class="col-sm-4 control-label"></label>
                <div class="col-sm-8" style="padding:0px">
                    <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                </div>
            </div>
            <!--<div class="form-group col-sm-3" style="margin-bottom:10px"  >
                <label  class="col-sm-4 control-label" >年份：</label>
                <select name="yearid" class="col-sm-8">
                    <option value="">&#45;&#45;请选择&#45;&#45;</option>
                    {loop $year $y}
                    <option value="{$y['yearid']}" class="form-control" {if $yearid == $y['yearid']}selected{/if}>{$y['yearid']}</option>
                    {/loop}
                </select>
            </div>-->

            <div style="clear:both"></div>
        </form>
    </div>

    <div style="margin-top: 25px">
        <div class="list-group">
            <p class="list-group-item " style="background-color: #D9EDF7">课程列表 <a style="float: right;margin-top: -6px;" href="{php echo $this->createWebUrl('lesson',array('op'=>'downloadlesson','kname'=>$kname,'date'=>$date,'subjectid'=>$subjectid,'teacherid'=>$teacherid,'classid'=>$classid,'semesterid'=>$semesterid,'voidtypeid'=>$voidtypeid,'isonly'=>$isonly,'price_type'=>$price_type))}" class="btn btn-success">导出</a></p>
            <div active="list-group-item" style="border:1px solid #cecece;margin-bottom: 15px">
                <table class="table table-hover table-bordered" style="margin-top:25px;width:98%;text-align:center;/*table-layout: fixed;*/"  align="center">
                    <thead>
                    <tr>
                        <th style="width: 90px;text-align:center;">
                            {if $order_type == 2}
                            <a href="{php echo $this->createWebUrl('lesson',['op'=>'list','order_type'=>1,'kname'=>$kname,'date'=>$date,'subjectid'=>$subjectid,'teacherid'=>$teacherid,'classid'=>$classid,'semesterid'=>$semesterid,'voidtypeid'=>$voidtypeid,'isonly'=>$isonly,'price_type'=>$price_type])}">排序值
                                <img src="{php echo MODULE_URL.'images/up.png'}" alt="" style="height: 14px;">
                            </a>
                            {elseif $order_type == 1}
                            <a href="{php echo $this->createWebUrl('lesson',['op'=>'list','order_type'=>2,'kname'=>$kname,'date'=>$date,'subjectid'=>$subjectid,'teacherid'=>$teacherid,'classid'=>$classid,'semesterid'=>$semesterid,'voidtypeid'=>$voidtypeid,'isonly'=>$isonly,'price_type'=>$price_type])}">排序值
                                <img src="{php echo MODULE_URL.'images/down.png'}" alt="" style="height: 14px;">
                            </a>
                            {/if}
                        </th>
                        <th style="width: 90px;text-align:center;">课程ID</th>
                        <th style="width: 90px;text-align:center;">课程标题</th>
                        <th style="width: 90px;text-align:center;">课次</th>
                        <th style="width: 90px;text-align:center;">课程类型</th>
                        <th style="width: 90px;text-align:center;">学科</th>
                        <th style="width: 90px;text-align:center;">讲师</th>
                        <th style="width: 90px;text-align:center;">
                            {if $price_order == 2}
                            <a href="{php echo $this->createWebUrl('lesson',['op'=>'list','price_order'=>1,'kname'=>$kname,'date'=>$date,'subjectid'=>$subjectid,'teacherid'=>$teacherid,'classid'=>$classid,'semesterid'=>$semesterid,'voidtypeid'=>$voidtypeid,'isonly'=>$isonly,'price_type'=>$price_type])}">
                                价格 <img src="{php echo MODULE_URL.'images/up.png'}" alt="" style="height: 14px;"></a>
                            </a>
                            {elseif $price_order ==1}
                            <a href="{php echo $this->createWebUrl('lesson',['op'=>'list','price_order'=>2,'kname'=>$kname,'date'=>$date,'subjectid'=>$subjectid,'teacherid'=>$teacherid,'classid'=>$classid,'semesterid'=>$semesterid,'voidtypeid'=>$voidtypeid,'isonly'=>$isonly,'price_type'=>$price_type])}">
                                价格 <img src="{php echo MODULE_URL.'images/down.png'}" alt="" style="height: 14px;"></a>
                            </a>
                            {/if}
                        </th>
                        <th style="width: 90px;text-align:center;">
                            {if $signupnum == 2}
                                <a href="{php echo $this->createWebUrl('lesson',['op'=>'list','signupnum'=>1,'kname'=>$kname,'date'=>$date,'subjectid'=>$subjectid,'teacherid'=>$teacherid,'classid'=>$classid,'semesterid'=>$semesterid,'voidtypeid'=>$voidtypeid,'isonly'=>$isonly,'price_type'=>$price_type])}">
                                    报名人数 <img src="{php echo MODULE_URL.'images/up.png'}" alt="" style="height: 14px;">
                                </a>
                            {elseif $signupnum == 1}
                                <a href="{php echo $this->createWebUrl('lesson',['op'=>'list','signupnum'=>2,'kname'=>$kname,'date'=>$date,'subjectid'=>$subjectid,'teacherid'=>$teacherid,'classid'=>$classid,'semesterid'=>$semesterid,'voidtypeid'=>$voidtypeid,'isonly'=>$isonly,'price_type'=>$price_type])}">
                                    报名人数<img src="{php echo MODULE_URL.'images/down.png'}" alt="" style="height: 14px;">
                                </a>
                            {/if}
                        </th>
                        <th style="width: 90px;text-align:center;">观看人次</th>
                        <th style="width: 190px;text-align:center;">状态</th>
                        <th style="width: 120px;text-align:center;">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $lessonlist $row}
                    <tr>
                        <td class="paixu" id="{$row['id']}">{$row['order']}</td>
                        <td>{$row['id']}</td>
                        <td style="{if $row['errornum'] > 0}color:red{/if}">{$row['title']}</td>
                        <td>{if $row['is_only'] == 2}系列课{elseif $row['is_only'] == 1}单节课{/if}</td>
                        <td>{$row['vname']}</td>
                        <td>{$row['sname']}</td>
                        <td>{$row['tname']}</td>
                        <td>{$row['pay_money']}</td>
                        <td>{$row['signupnum']}</td>
                        <td>{$row['study_num']}</td>
                        <!--<td>{$row['order']}</td>-->
                        <td>
<!--                            <div class="btn {if $row['status'] == 0}btn-danger{else}btn-info{/if}" data="{$row['id']}"-->
<!--                                 onclick="changestatus(this)">{if $row['status'] == 0}已下架{else}已上架{/if}-->
<!--                            </div>-->
                            {if $row['status'] == 0}
                            <a data-toggle="modal" onclick="changestatus(this)" data="{$row['id']}" class="btn btn-danger">已下架</a>
                            {else}
                            <a data-toggle="modal" onclick="changestatus(this)" data="{$row['id']}" class="btn btn-info">已上架</a>
                            {/if}

<!--                            <a href="javascript:void(0)" class="btn {if $row['recommend'] == 0}btn-danger{else}btn-info{/if}"-->
<!--                               onclick="recommend(this)" data='{$row["id"]}'>{if $row['recommend'] == 0}未推荐{else}已推荐{/if}</a>-->


                            {if $row['recommend'] == 0}
                            <a data-toggle="modal" onclick="recommend(this)" data="{$row['id']}" class="btn btn-danger">未推荐</a>
                            {else}
                            <a data-toggle="modal" onclick="recommend(this)" data="{$row['id']}" class="btn btn-info">已推荐</a>
                            {/if}




                        </td>
<!--                        <td>-->
<!--                            <a href="#addclasstype " data-toggle="modal" onclick="edit({$row['id']})" class="btn btn-primary">编辑</a>-->
<!--                            <a href="{php echo $this->createWebUrl('index',array('op'=>'setting','type'=>'classtype','oop'=>'delete','classtypeid'=>$row['id']))}" class="btn btn-danger">删除</a>-->
<!--                        </td>-->

                        <td>
						<div class="btn-group">
							<button class="btn btn-default" disabled>操作</button>
							<button data-toggle="dropdown" class="btn btn-default dropdown-toggle"><span class="caret"></span></button>
							<ul class="dropdown-menu">
								<li>
                                    <a href="{php echo $this->createWebUrl('son',array('op'=>'list','lid'=>$row['id']))}">章节管理</a>
								</li>
                                {if $row['is_underline'] == 1}
                                <li >
                                    <a href="{php echo $this->createWebUrl('lesson',array('op'=>'underline_list','lesson_id'=>$row['id']))}">线下学员名单</a>
                                </li>
                                {/if}
                                <li>
                                    <a href="{php echo $this->createWebUrl('lesson',array('op'=>'lessondown','lessonid'=>$row['id']))}">导出信息</a>
                                </li>
                                {if $row['qrcode']}
                                <li>
                                    <a href="javascript:void(0)" onclick="qrcode({$row['id']})">更新静态码</a>
                                    <a href="{php echo $this->createWebUrl('lesson',array('op'=>'download','lessonid'=>$row['id']))}">下载小程序码</a>
                                </li>
                                {else}
                                <li>
                                    <a href="javascript:void(0)" onclick="qrcode({$row['id']})">获取静态码</a>
                                </li>
                                {/if}

                                <li>
                                    <a href="{php echo $this->createWebUrl('lesson',array('op'=>'post','id'=>$row['id']))}">编辑</a>
                                </li>
                                <li>
                                    <a href="{php echo $this->createWebUrl('lesson',array('op'=>'delete','id'=>$row['id']))}">删除</a>
                                </li>
							</ul>
						</div>
					</td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
            {$page}
        </div>
    </div>
</div>
<script type="text/javascript">
    function changestatus(obj) {
        var obj = $(obj);
        if (obj.hasClass('btn-danger')) {
            var sta = 1;
        } else {
            var sta = 0;
        }
        var id = obj.attr('data');
        $.ajax({
            type: 'post',
            url: "{php echo $this->createWebUrl('lesson',array('op'=>'cstatus'))}",
            data: {sta: sta, id: id},
            success: function (res) {
                var res = JSON.parse(res);
                console.log(res);
                if (res.success == 1) {
                    if (sta == 1) {
                        obj.removeClass('btn-danger');
                        obj.addClass('btn-info');
                        obj.html('已上架');
                    } else {
                        obj.removeClass('btn-info');
                        obj.addClass('btn-danger');
                        obj.html('已下架');
                    }
                } else {
                    alert(res.mess);
                }
            }
        });
    }

    function qrcode(lessonid) {
        var lessonid = lessonid;
        $.ajax({
            type: 'post',
            url: "{php echo $this->createWebUrl('lesson',array('op'=>'qrcode'))}",
            data: {lessonid: lessonid},
            success: function (res) {
                var res = JSON.parse(res);
                if (res.success == 1) {
                    location.reload();
                }
            }
        });
    }

    function recommend(obj) {
        var obj = $(obj);
        var id = obj.attr('data');
        if (obj.hasClass('btn-danger')) {
            var sta = 1;
        } else {
            var sta = 0;
        }
        $.ajax({
            type: 'post',
            url: "{php echo $this->createWebUrl('lesson',array('op'=>'recommend'))}",
            data: {id: id, sta: sta},
            success: function (res) {
                console.log(res);
                var res = JSON.parse(res);
                if (res.success == 1) {
                    if (sta == 1) {
                        obj.removeClass('btn-danger');
                        obj.addClass('btn-info');
                        obj.html('已推荐');
                    } else {
                        obj.removeClass('btn-info');
                        obj.addClass('btn-danger');
                        obj.html('未推荐');
                    }
                } else {
                    alert(res.mess);
                }

            }
        });
    }

    $(function(){
        $('.paixu').click(function(){
            if(!$(this).is('.input')){
                $(this).addClass('input').html('<input type="text" id="'+$(this).attr("id") +'" style="width: 50px;" value="'+ $(this).text() +'" />').find('input').focus().blur(function(){
                    var order=$(this).val();
                    var id=$(this).attr("id");
                    $.ajax({
                        type: 'POST',
                        url: "{php echo $this->createWebUrl('lesson',array('op'=>'sort'))}",
                        data: {lid:id,order:order},
                        success:function(res){
                            var res = JSON.parse(res);
                            location.reload();
                        }
                    });
                    $(this).parent().removeClass('input').html($(this).val() || 0);
                });
            }
        }).hover(function(){
            $(this).addClass('hover');
        },function(){
            $(this).removeClass('hover');
        });
    });
</script>
<div id="modal-module-menus" class="modal fade" tabindex="-1">
    <div class="modal-dialog" style='width: 920px;'>
        <div class="modal-content">
            <div class="modal-body">
                <div id="module-menus" style="padding-top:5px;"></div>
            </div>
            <div class="modal-footer"><a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>
<script>
    function choice(lid) {
//	    请求获取模块信息
        $.ajax({
            type: 'post',
            url: "{php echo $this->createWebUrl('lesson',array('op'=>'module','id'=>$row['id']))}",
            data: {op: 'module', lid: lid},
            success: function (res) {
                popwin = $('#modal-module-menus').modal();
                $('#module-menus').html(res);
            }
        });
    }
    function select_module(mid, lid) {
        var mid = mid;
        var lid = lid;
        console.log(mid, lid);
//        更新课程表中的module字段
        $.ajax({
            type: 'post',
            url: "{php echo $this->createWebUrl('lesson')}",
            data: {op: 'selectm', mid: mid, lid: lid},
            success: function (res) {
                var res = JSON.parse(res);
                console.log(res);
                if (res.success == 1) {
                    alert(res.mess);
                    location.href = "{php echo $this->createWebUrl('lesson')}";
                } else {
                    alert(res.mess);
                }
            }
        });

    }
</script>
{elseif $op == 'post'}
<div class="list-group">
    <p class="list-group-item active" style="background-color: #D9EDF7;border:1px solid #D9EDF7;color:#31708F">课程设置</p>
    <div active="list-group-item " style="border:1px solid #cecece">
        <form action="" method="post" class="form-horizontal">
            <!--3.0但章节课程 或 系列课程选择-->
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">课程课次</label>
                <div class="col-sm-10">
                    <label class="radio-inline">
                        <input type="radio" name="is_only" {if $info['is_only'] == 2 || empty($info['is_only'])}checked{/if} value="2" title="系列课"> 系列课
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="is_only" {if $info['is_only'] == 1}checked{/if} value="1" title="单节课"> 单节课
                    </label>
                    <span class="help-block">系列课包含多个章节，单节课仅有一个章节！默认为系列课</span>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label"><span style="color:red">*</span>标题</label>
                <div class="col-sm-10">
                    <input type="text" name="title" value="{$info['title']}" class="form-control" style="width:98%"/>
                    <span class="help-block">课程标题建议在10个字符之内</span>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label"><span style="color:red">*</span>课程封面图：</label>
                <div class="col-sm-10">
                    {php echo tpl_form_field_image('image',$info['image'])}
                    <span class="help-block">建议图片比例为：<span style="color:red">648*416</span></span>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">线下课程</label>
                <div class="col-sm-10">
                    <label class="radio-inline">
                        <input type="radio" name="is_underline" {if $info['is_underline'] == 0}checked{/if} value="0" title="否"> 否
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="is_underline" {if $info['is_underline'] == 1}checked{/if} value="1" title="是" >
                        是
                    </label>
                    <span class="help-block">若不选择,默认线上课程.线下课程不可线上购买！</span>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-10">
                    <label class="radio-inline">
                        <input type="radio" name="status" {if $info['status'] == 0}checked{/if} value="0" title="下架"> 下架
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="status" {if $info['status'] == 1}checked{/if} value="1" title="上架" >
                        上架
                    </label>
                    <span class="help-block">若不选择，默认下架</span>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label"><span style="color:red">*</span>主讲老师</label>
                <div class="col-sm-10">
                    <select name="teacherid" style="width:98%" id="teacher">
                        <option value="">--请选择讲师--</option>
                        {loop $teacherlist $t}
                        <option value="{$t['id']}" {if $t['id'] == $info['tid']}selected{/if}>{$t['name']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">助教老师</label>
                <div class="col-sm-10">
                    <select name="help_teacherid" style="width:98%" id="help_teacher">
                        <option value="">--请选择助教老师--</option>
                        {if !empty($id)}
                        {loop $help_teacherlist $row}
                        <option value="{$row['id']}" {if $info['help_teacherid'] == $row['id']}selected{/if}>{$row['name']}</option>
                        {/loop}
                        {/if}
                    </select>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label"><span style="color:red">*</span>学科</label>
                <div class="col-sm-10">
                    <input type="text" name="subject" value="{$info['sname']}" class="form-control" style="width:98%"
                           disabled>
                    <input type="hidden" name="subjectid" value="{$info['sid']}" class="form-control" style="width:98%">
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label"><span style="color:red">*</span>城市</label>
                <div class="col-sm-10">
                    <input type="text" name="city" value="{$info['cname']}" class="form-control" style="width:98%"
                           disabled>
                    <input type="hidden" name="cityid" value="{$info['cid']}" class="form-control" style="width:98%">
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">学期</label>
                <div class="col-sm-10">
                    <select name="semesterid" style="width:98%">
                        <option value="">--请选择学期--</option>
                        {loop $semester $se}
                        <option value="{$se['id']}" {if $se['id'] == $info['seid']}selected{/if}>{$se['name']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
            <!--3.0添加班型选择-->
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">班型</label>
                <div class="col-sm-10">
                    <select name="classtypeid" style="width:98%">
                        <option value="">--请选择班型--</option>
                        {loop $classtypelist $se}
                        <option value="{$se['id']}" {if $se['id'] == $info['classtypeid']}selected{/if}>{$se['name']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label"><span style="color:red">*</span>年级</label>
                <div class="col-sm-10" id="subject">
                    {if $info['tid'] != ''}
                    {loop $class $row}
                    <label class="checkbox-inline">
                        <input type="checkbox" name="classid[]" value="{$row['id']}" {if $info['classid']}{if in_array($row['id'],$info['classid'])}checked{/if}{/if}> <span style="margin-right:15px">{$row['name']}</span></label>
                    {/loop}
                    {else}
                    <span style="height: 34px!important;line-height: 34px">请先选择讲师</span>
                    {/if}

                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label"><span style="color:red">*</span>课程类型</label>
                <div class="col-sm-10">
                    <select name="voidtypeid" style="width:98%">
                        <option value="">--请选择课程类型--</option>
                        {loop $voidtype $v}
                        <option value="{$v['id']}" {if $v['id'] == $info['vid']}selected{/if}>{$v['name']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label"><span style="color:red">*</span>年份</label>
                <div class="col-sm-10">
                    <select name="yearid" style="width:98%">
                        <!--<option value="">&#45;&#45;请选择年份&#45;&#45;</option>-->
                        <option value="{php echo date('Y');}" {if $info['yearid'] == intval(date('Y'))}selected="selected"{/if}>{php echo date('Y');}年</option>
                        <option value="{php echo date('Y')-1;}" {if $info['yearid'] == intval(date('Y')-1)}selected="selected"{/if}>{php echo date('Y')-1;}年</option>
                        <option value="{php echo date('Y')-2;}" {if $info['yearid'] == intval(date('Y')-2)}selected="selected"{/if}>{php echo date('Y')-2;}年</option>
                    </select>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-10">
                    <input type="number" name="order" value="{if empty($info['order'])}0{else}{$info['order']}{/if}" class="form-control" style="width:98%"/>
                    <span class="help-block">请填写0到100的数字，数字越大排序越靠前</span>
                </div>
            </div>
            <!--3.0 课程购买价格及方式-->
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">课程购买方式：</label>
                <div class="col-sm-10">
                    <label class="radio-inline">
                        <input type="radio" name="paytype" {if $info['paytype'] == 2 || empty($info['paytype'])}checked{/if} value="2" title="免费"> 免费
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="paytype" {if $info['paytype'] == 3}checked{/if} value="3" title="付费（兑换币）" > 付费（兑换币）
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="paytype" {if $info['paytype'] == 4}checked{/if} value="4" title="付费（人民币）" > 付费（人民币）
                    </label>
                    <span class="help-block">用户获得课程权限的方式</span>
                </div>
            </div>
            <!--兑换币购买课程-->
            <div class="form-group xhb" style="margin-top:25px ;{if $info['paytype'] != 3 }display:none;{/if}">
                <label class="col-sm-2 control-label">课程价格：</label>
                <div class="col-sm-10">
                    <input type="number" name="xhbnumber" value="{$info['xhbnumber']}" class="form-control"/>
                    <span class="help-block">报名课程所需要的兑换币数量，默认为1</span>
                </div>
            </div>
            <!--人民币购买课程 包括原价购买  拼团购买-->
            <div class="form-group rmb" style="margin-top:25px ;{if $info['paytype'] != 4 }display:none;{/if}">
                <label class="col-sm-2 control-label">课程价格：</label>
                <div class="col-sm-10">
                    <input type="text" name="pay_money" id="pay_money" value="{if empty($info['pay_money'])}0.00{else}{$info['pay_money']}{/if}" class="form-control" style="width:98%" onfocus="this.value=''" onblur="if( ! /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.value) || Number(this.value)>=50000){alert('只能输入数字，小数点后只能保留两位');this.value='';}">
                    <span class="help-block">报名课程需要金额</span>
                </div>
            </div>
            <div class="form-group rmb" style="margin-top:25px ;{if $info['paytype'] != 4 }display:none;{/if}">
                <label class="col-sm-2 control-label">是否开启团购：</label>
                <div class="col-sm-10">
                    <label class="radio-inline">
                        <input type="radio" name="is_groupbuy" {if $info['is_groupbuy'] == 2 || empty($info['is_groupbuy'])}checked{/if} value="2" title="不开启"> 不开启
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="is_groupbuy" {if $info['is_groupbuy'] == 1}checked{/if} value="1" title="可团购" > 开启
                    </label>
                    <span class="help-block">课程是否允许拼团购买，默认不开启</span>
                </div>
            </div>
            <div class="form-group groupprice"
                 style="margin-top:25px ;{if $info['is_groupbuy'] != 1 }display:none;{/if}">
                <label class="col-sm-2 control-label">团购价格：</label>
                <div class="col-sm-10">
                    <input type="text" name="old_money"  value="{if empty($info['old_money'])}0.00{else}{$info['old_money']}{/if}" class="form-control" style="width:98%" onfocus="this.value=''" onblur="console.log($('#pay_money').val());console.log(this.value);if( ! /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.value) || Number(this.value)>=50000 || Number(this.value) > Number($('#pay_money').val())) {alert('价格输入错误');this.value='';}">
                    <span class="help-block">报名课程需要金额</span>
                </div>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">课程简介</label>
                <div class="col-sm-10">
                    {php echo tpl_ueditor('desc',$info['desc']);}
                   <!-- <span class="help-block">课程简介小程序 PC h5通用一个</span>-->
                </div>
            </div>

            <div class="form-group" style="margin-top:25px;display: none;">
                <label class="col-sm-2 control-label">PC首页分类</label>
                <div class="col-sm-10">
                    <select name="pctype" style="width:98%">
                        <option value="1" {if $info['pctype']==1}selected{/if}>精品公开课</option>
                        <option value="2" {if $info['pctype']==2}selected{/if}>干货短期班</option>
                        <option value="3" {if $info['pctype']==3}selected{/if}>热门常规课</option>
                    </select>
                    <p class="help-block">此参数仅作为PC端首页分类使用</p>
                </div>
            </div>

            <div class="form-group" style="margin-top:25px">
                <label class="col-sm-2 control-label">虚拟学习人数</label>
                <div class="col-sm-10">
                    <input type="number" name="fic_study_num"
                           value="{if empty($info['fic_study_num'])}0{else}{$info['fic_study_num']}{/if}"
                           class="form-control" style="width:98%" onfocus="this.value=''"/>
                    <p class="help-block">此数值为虚拟数值</p>
                </div>
            </div>
            <!--<hr>-->
            <!--{if $config['pay_status'] == 100 }
            <div class="form-group" style="margin-top:25px">
                <label  class="col-sm-2 control-label"><span style="color:red">*</span>课程售价</label>
                <div class="col-sm-10">

                </div>
                <span style='color: #cecece;font-size: 14px;margin-left: 197px'>
                    您已开启支付功能，请确定课程价格，用户购买课程后可观看课程下所有章节。
                </span>
            </div>
            <div class="form-group" style="margin-top:25px">
                <label  class="col-sm-2 control-label">PC-课程原价</label>
                <div class="col-sm-10">

                    <p style="color: #cecece;">PC端显示课程原价需大于课程售价，默认为0.00</p>
                </div>
            </div>
            {/if}-->
            <!--<div class="form-group" style="margin-top:25px">
                <label  class="col-sm-2 control-label">PC-课程封面图片</label>
                <div class="col-sm-10">
                    {php echo tpl_form_field_image('image',$info['image'])}
                    <span>建议图片尺寸为：<span style="color:red">720*360</span></span>
                </div>
            </div>-->
            <!--<div class="form-group" style="margin-top:25px">
                <label  class="col-sm-2 control-label">PC-虚拟购买人数</label>
                <div class="col-sm-10">
                    <input type="number" name="fic_pay_num" value="{if empty($info['fic_pay_num'])}0{else}{$info['fic_pay_num']}{/if}"    class="form-control" style="width:98%" onfocus="this.value=''"/>
                    <p style="color: #cecece;">此数值为虚拟数值</p>
                </div>
            </div>-->
            <!--<div class="form-group" style="margin-top:25px">
                <label  class="col-sm-2 control-label">PC-优惠名额</label>
                <div class="col-sm-10">
                    <input type="number" name="free_num" value="{if empty($info['free_num'])}0{else}{$info['free_num']}{/if}"    class="form-control" style="width:98%" onfocus="this.value=''"/>
                    <p style="color: #cecece;">此数值为虚拟数值</p>
                </div>
            </div>-->
            <!--<div class="form-group" style="margin-top:25px">
                <label  class="col-sm-2 control-label">PC-课程介绍</label>
                <div class="col-sm-10">
                    {php echo tpl_ueditor('pc_description',$info['pc_description']);}
                </div>
            </div>-->
            <input type="hidden" name="id" value="{$id}">
            <input type="hidden" name="token" value="{$_W['token']}">
            <div style="float: right;margin:10px">
                <input type="submit" name="submit" value="保存设置" class="btn btn-info" onclick="return checksubmit();">
            </div>
            <div style="clear: both;"></div>
        </form>
    </div>
</div>
<script type="text/javascript">
    $('#teacher').change(function () {
        var teacherid = $(this).val();
        var url = "./index.php?c=site&a=entry&m=goouc_class&do=lesson&op=post";
        var subject = $('#subject');
        subject.empty();
        var help_teacher = $('#help_teacher');
        help_teacher.empty();
        help_teacher.append('<option value="">--选择助教老师--</option>');

        $.get(url, {teacherid: teacherid}, function (res) {
            $('input[name="city"]').val(res.city.name);
            $('input[name="cityid"]').val(res.city.id);
            $('input[name="subject"]').val(res.subject.name);
            $('input[name="subjectid"]').val(res.subject.id);
            for (var i = 0; i < res.class.length; i++) {
                var option = `<input type="checkbox" name="classid[]" value="${res.class[i]['id']}"><span style="margin-right:15px"> ${res.class[i]['name']}</span>`;
                subject.append(option);
            }
            ;
            for (var i = 0; i < res.help_teacher.length; i++) {
                var option2 = `<option value="${res.help_teacher[i]['id']}">${res.help_teacher[i]['name']}</option>`;
                help_teacher.append(option2);
            }
            ;
        }, "JSON");
    });
    //改变课程支付方式
    $('input[name="paytype"]').change(function () {
        if ($(this).val() == 2) {
            $('.xhb').hide();
            $('.rmb').hide();
            $('.groupprice').hide();
        } else if ($(this).val() == 3) {
            $('.xhb').show();
            $('.rmb').hide();
        } else if ($(this).val() == 4) {
            $('.xhb').hide();
            $('.rmb').show();
        }
    });
    $('input[name="is_groupbuy"]').change(function () {
        if ($(this).val() == 1) {
            $('.groupprice').show();
        } else if ($(this).val() == 2) {
            $('.groupprice').hide();
        }
    });
    //验证提交表单
    function checksubmit() {
        var flag = true;
        if ($('input[name="title"]').val() == '') {
            flag = false;
            xhToast('请填写课程标题');
            return flag;
        }
        if ($('input[name="image"]').val() == '') {
            flag = false;
            xhToast('请选择课程封面图片');
            return flag;
        }
        if (!$('select[name="teacherid"]').val()) {
            flag = false;
            xhToast('请选择课程讲师');
            return flag;
        }
        /*if (!$('select[name="semesterid"]').val()) {
            flag = false;
            xhToast('请选择课程班期');
            return flag;
        }*/
        /*if (!$('select[name="classtypeid"]').val()) {
         flag = false;
         xhToast('请选择课程班型');
         return flag;
         }*/
        if (!$('input[type="checkbox"]').is(':checked')) {
            flag = false;
            xhToast('请选择课程年级');
            return flag;
        }
        if (!$('select[name="voidtypeid"]').val()) {
            flag = false;
            xhToast('请选择课程类型');
            return flag;
        }
        /*if (!$('select[name="help_teacherid"]').val()) {
         flag = false;
         xhToast('请选择课程助教老师');
         return flag;
         }*/
        if ($('input[name="paytype"]:checked').val() == 3 && $('input[name="xhbnumber"]').val() == '') {
            flag = false;
            xhToast('请设置课程消耗兑换币的数量');
            return flag;
        }
        if ($('input[name="paytype"]:checked').val() == 4 && $('input[name="pay_money"]').val() == '') {
            flag = false;
            xhToast('请设置课程购买价格');
            return flag;
        }
        if ($('input[name="paytype"]:checked').val() == 4 && $('input[name="pay_money"]').val() != '' && $('input[name="old_money"]').val() == '') {
            flag = false;
            xhToast('请设置课程团购价格');
            return flag;
        }
        return flag;
    }

    //公用提示窗
    function xhToast(_text) {
        $('body').append("<div class='xh-toast-block'>" + _text + "</div>");
        setTimeout(function () {
            $('.xh-toast-block').remove();
        }, 2000);
    }
</script>
{elseif $op == 'underline_list'}
    <div class="panel panel-default">
        <div class="panel-body table-responsive">
            <p>{$lessontitle}</p>
            <a href="{php echo $this->createWebUrl('lesson', array('op' => 'editunderline','lesson_id'=>$lesson_id))}" class="btn btn-success" data-toggle="modal"  style="float:right;margin: 15px">新增学员</a>
            <div style="float:right;margin-top:15px;position: relative;" >
                <span class='btn btn-success' >导入学员</span>
                <form  class="form_upload_form" action="#" name="form_end" id="biaoge" method="post" enctype="multipart/form-data" style="position:absolute;top:0;left:0;height: 34px;width: 84px;">
                    <input class="btn btn-success" style="opacity:0;width: 84px;height:34px;" class="form-control" type="file" name="biaoge" onchange="up(this)">
                </form>
            </div>
            <a href="../addons/goouc_class/example/example_user.xls" class="btn btn-success" data-toggle="modal"  style="float:right;margin: 15px">下载导入模板</a>
            <table class="table table-hover">
                <thead class="navbar-inner">
                <tr>
                    <th style="width:40px">ID</th>
                    <th style="width:80px">姓名</th>
                    <th style="width:80px">电话</th>
                    <th style="width:80px">操作</th>
                </tr>
                </thead>
                <tbody>
                    {loop $list $item}
                    <tr>
                        <td>{$item['id']}</td>
                        <td>{$item['username']}</td>
                        <td>{$item['phone']}</td>
                        <td style="text-align:left;">
                            <a href="{php echo $this->createWebUrl('lesson', array('op' => 'editunderline', 'id' => $item['id'],'lesson_id'=>$item['lesson_id']))}" class="btn btn-default btn-sm">修改</a>
                            <a href="{php echo $this->createWebUrl('lesson', array('op' => 'delunderline', 'id' => $item['id'], 'lesson_id'=>$item['lesson_id']))}" onclick="return confirm('确认删除吗？');return false;" title="删除" data-toggle="tooltip" data-placement="bottom" class="btn btn-default btn-sm">删除</a>
                        </td>
                    </tr>
                    {/loop}
                </tbody>
            </table>
            {$pager}
        </div>
    </div>
<!--    <a href="{php echo $this->createWebUrl('lesson', array('op' => 'editunderline','lesson_id'=>$lesson_id))}" class="btn btn-success"><i class="fa fa-plus"></i> 新增学员</a>-->

<!--    <div style="height:36px; width: 300px;">-->
<!--        <div style="position:relative;float: left;">-->
<!--            <span class='btn btn-success' >-->
<!--                选择文件-->
<!--            </span>-->
<!--            <form  class="form_upload_form" action="#" name="form_end" id="biaoge" method="post" enctype="multipart/form-data" style="position:inline-block;">-->
<!--                <input style="width:82px;opacity:0;padding:0;position:absolute;top:0px;left: 0px" class="form-control" type="file" name="biaoge" onchange="up(this)">-->
<!--            </form>-->
<!--        </div>-->
<!--    </div>-->
    
    <script type="text/javascript">
        window.up = function(e) {
            var t = new FormData(document.getElementById("biaoge"));
            post_biaoge("{php echo $this->createWebUrl('lesson',array('op'=>'uploadunderline','lesson_id'=>$lesson_id))}", t,
                function(e) {
                    console.log(e);
                    // alert('上传成功');
                    location.reload();
                });
        };
        post_biaoge = function (e, t, a) {
            $.ajax({
                type: "POST",
                url: e,
                data: t,
                cache: !1,
                contentType: !1,
                processData: !1,
                success: function(e) {
                    console.log(e);
                    var e = JSON.parse(e);
                    200 == parseInt(e.code) && a(e.mess)
                },
                error: function(e, t, a) {
                    $(".modal-body").text("上传失败，请检查网络后重试"),
                        $(".tishi").show(),
                        $(".success").hide(),
                        $("#myModal").modal("show")
                }
            })
        };
    </script>

{elseif $op == 'editunderline'}
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
        <div class="panel panel-info">
            <div class="panel-heading">
                <input type="hidden" name="id" value="{$info['id']}" />
                线下学员
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">姓名</label>
                    <div class="col-xs-12 col-sm-9">
                        <input type="text" class="form-control" placeholder="姓名" name="username" id="username" value="{$info['username']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">电话</label>
                    <div class="col-xs-12 col-sm-9">
                        <input type="text" class="form-control" placeholder="电话" name="phone" value="{$info['phone']}" />
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-12">
            <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
            <input type="hidden" name="token" value="{$_W['token']}" />
            <input type="hidden" name="lesson_id" value="{$lesson_id}" />
        </div>
    </form>
    <script language='javascript'>
        function formcheck() {
            return true;
        }
    </script>

{/if}

{template "common/footer"}